package com.example.aopdemo.aspact;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class AopDemo {

  @Pointcut("@annotation(com.example.aopdemo.aspact.annotation.DemoLog)")
  public void pointCut(){

  }

  @Around("pointCut()")
  public Object Around(ProceedingJoinPoint point) throws Throwable {
     long beginTime = System.currentTimeMillis();

     Object proceed = point.proceed();

     long time  = System.currentTimeMillis() - beginTime;
     sysLog(point,time);
     return  proceed;
  }

  private void  sysLog(ProceedingJoinPoint point,long time){
      System.out.println("1111");
  }

//  @Before("pointCut()")
//  public void testBefor(){
//      System.out.println("2222");
//  }
//
//  @After("pointCut()")
//  public void testAfter(){
//      System.out.println("23333");
//  }
}
